package com.clz.latte.ec.database;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

/**
 * Created by Administrator on 2018/3/5.
 */

public class DataBaseManager {
    private DaoSession mDaoSession = null;
    private UserProfileDao mDao = null;

    private static final class HOLDER {
        private static final DataBaseManager INSTANCE = new DataBaseManager();
    }

    public static DataBaseManager getInstance() {
        return HOLDER.INSTANCE;
    }

    private DataBaseManager() {
    }

    public DataBaseManager init(Context context) {
        initDao(context);
        return this;
    }

    public void initDao(Context context) {
        final RelaseOpenHelper helper = new RelaseOpenHelper(context, "fest_ec.db");
        final SQLiteDatabase db = helper.getWritableDatabase();
        mDaoSession = new DaoMaster(db).newSession();
        mDao = mDaoSession.getUserProfileDao();
    }

    public final UserProfileDao getDao() {
        return mDao;
    }
}
